<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>{$Think.config.site.title} - OTA升级安装包</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>
<style>
    #listtable .fa{
        cursor:pointer;
        color:#1ab394;
        margin-right:1em;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>{:lang('机柜版本管理')}</h5>

                </div>
                <div class="ibox-content" >
                    <div class="row">
                        <div class="col-sm-3">
                            <button type="button" class="btn btn-sm btn-primary" id="addBtn"> {:lang('添加内容')}</button>
                            <!-- <button type="button" class="btn btn-sm btn-success" id="saveSelected"> 保存排序</button> </span> -->
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped" id="listtable">
                            <thead>
                            <tr>
                                <th>{:lang('版本')}</th>
                                <th>{:lang('版本描述')}</th>
                                <th>{:lang('升级包名称')}</th>
                                <th>{:lang('创建时间')}</th>
                                <th>{:lang('操作')}</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list" id="vo"}
                            <tr data-id="{$vo.id}" >
                                <td>{$vo.version}</td>
                                <td>{$vo.version_desc}</td>
                                <td>{$vo.file_name}</td>
                                <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                                <td><i class="fa fa-trash-o"> {:lang('删除')}</i></td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                    <div></div>

                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all"></div>
                    </div>
                    <div class="col-sm-6">
                        <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                            {$list->render()}
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
</div>

<script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
<script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
<script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
<script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
<script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
</body>

</html>
<script>
    var layer_font;
    var $editTr;
    $(document).ready(function() {
        $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
        //新增按钮
        $("#addBtn").bind("click",function(){
            layer_font = layer.open({
                type: 2,
                title: "{:lang('机柜版本信息内容添加')}",
                shadeClose: true,
                shade: 0.8,
                area: ['30%', '40%'],
                content: '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Equipment/otadd' //iframe的url
            });
        });

        //删除按钮注册
        $("#listtable").on("click",".fa-trash-o",function(){
            var $tr = $(this).closest("tr");
            var did = $tr.data("id");
            layer.confirm("{:lang('确定要删除？')}", {
                    btn: ["{:lang('确定删除')}","{:lang('不删除')}"], //按钮
                    shade: false //不显示遮罩
                }, function(){
                    //确定删除
                    $.ajax({
                        type : 'POST',//delete
                        url : '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Equipment/ota?did='+did,
                        dataType : 'json',
                        data : {did:did},
                        async:false,
                        success : function(result) {
                            //layer.close(layer1);
                            if(0 === result.code) {
                                $tr.remove();
                                layer.msg(result.msg, {icon: 1});
                            }  else  {
                                //删除失败
                                layer.msg(result.msg, {icon: 5});
                            }
                        },
                        error : function(){
                            res = false;
                            layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                        }
                    })
                },
                function(){

                });


        });
    });
</script>